﻿#include "PFD.h"
//const float DEG2RAD = 3.14159265f / 180.0f;
//const int length = 872 / 1.5;           // l: 显示器长度
//const int wideth = 1123 / 1.5;
//const int x = 0;
//const int y = 0;
//struct FlightData {
//	float pitch;    // 俯仰角（度）
//	float roll;     // 横滚角（度）
//	float height;   // 高度（英尺）
//	float speed;
//};
static PIMAGE g_pfd_main_layer = NULL;
//DashboardData sharedData;
//起落架
void drawlunzi(int x, int y, int length, int wideth, double size) {
	setcolor(EGERGB(175, 175, 175));
	setlinewidth(2 * size);
	setfont(length * 0.0378, 0, "Tahoma");
	setbkmode(TRANSPARENT);
	outtextxy(x + length * 0.42, y + wideth * 0.85, "T.O THS FOR ");
	setcolor(EGERGB(0, 175, 0));
	outtextxy(x + length * 0.65, y + wideth * 0.85, "29");
	setcolor(EGERGB(0, 175, 175));
	outtextxy(x + length * 0.68, y + wideth * 0.85, "%");
	setcolor(EGERGB(177, 0, 177));
	ege_rectangle(x + length * 0.90, y + wideth * 0.85, length * 0.089, length * 0.055);
	outtextxy(x + length * 0.91, y + wideth * 0.86, "28");
	setcolor(EGERGB(0, 175, 175));
	outtextxy(x + length * 0.95, y + wideth * 0.86, "%");
}
//襟翼
void drawLanding(int x, int y, int length, int wideth, double landing, double size) {
	if (landing == 1) {
		setcolor(EGERGB(0, 175, 0));
		ege_point polypoints3[40] = { {x + (length / 5) * 0.6,y + wideth * 0.95},{x + (length / 5) * 0.8,y + wideth * 0.95},{x + (length / 5) * 0.8,y + wideth * 0.98},{x + (length / 5) * 0.6,y + wideth * 0.95} };
		ege_drawpoly(4, polypoints3);
		ege_point polypoints4[40] = { {x + (length / 5) * 1.05,y + wideth * 0.95},{x + (length / 5) * 0.85,y + wideth * 0.95},{x + (length / 5) * 0.85,y + wideth * 0.98},{x + (length / 5) * 1.05,y + wideth * 0.95} };
		ege_drawpoly(4, polypoints4);
		drawlunzi(x, y, length, wideth, size);
		//Wheel_indicator(x + 0.81 * length, y + 0.88 * wideth, size * 0.6, 0.25, 0.25);
	}
	else if (landing > 0 && landing < 1) {
		setcolor(EGERGB(255, 0, 0));
		ege_point polypoints3[40] = { {x + (length / 5) * 0.6,y + wideth * 0.95},{x + (length / 5) * 0.8,y + wideth * 0.95},{x + (length / 5) * 0.8,y + wideth * 0.98},{x + (length / 5) * 0.6,y + wideth * 0.95} };
		ege_drawpoly(4, polypoints3);
		ege_point polypoints4[40] = { {x + (length / 5) * 1.05,y + wideth * 0.95},{x + (length / 5) * 0.85,y + wideth * 0.95},{x + (length / 5) * 0.85,y + wideth * 0.98},{x + (length / 5) * 1.05,y + wideth * 0.95} };
		ege_drawpoly(4, polypoints4);
	}
}
// 独立绘制姿态仪函数
//上面第一块区域
void drawSpeedMax(int x, int y, int length, int wideth, double size) {
	setcolor(EGERGB(int(175), int(175), int(175)));
	setlinewidth(2 * size);
	ege_rectangle(x + length / 30, y + wideth * 0.0001, 55 * size, 40 * size);
	setfont(length * 0.0489, 0, "Tahoma");
	setbkmode(TRANSPARENT);
	ege_drawtext("MAN", x + length / 13, y + wideth / 150);
	outtextxy(x + length / 16, y + wideth / 30, "TOGA");
	//	outtextxy(x + length / 55, y + wideth / 11, "LVR");
	//	outtextxy(x + length / 8, y + wideth / 11, "CLB");
}
void drawSpeedMin(int x, int y, int length, int wideth, double size) {
	setcolor(EGERGB(int(175), int(175), int(175)));
	setlinewidth(2 * size);
	ege_rectangle(x + length / 30, y + wideth / 50, 55 * size, 40 * size);
	setfont(length * 0.0489, 0, "Tahoma");
	setbkmode(TRANSPARENT);
	outtextxy(x + length / 18, y + wideth / 50, "MAN");
	outtextxy(x + length / 18, y + wideth / 19, "MCT");
}
void drawSpeedMidum(int x, int y, int length, int wideth, double size) {
	setcolor(EGERGB(int(225), int(113), int(0)));
	setlinewidth(2 * size);
	ege_rectangle(x + length / 30, y + wideth / 50, 55 * size, 40 * size);
	setfont(length * 0.0489, 0, "Tahoma");
	setcolor(EGERGB(int(175), int(175), int(175)));
	setbkmode(TRANSPARENT);
	outtextxy(x + length / 18, y + wideth / 50, "MAN");
	outtextxy(x + length / 18, y + wideth / 19, "THR");
}
//高度表（实际上是空速）
void drawAirbusAltitudeScale(int x, int y, int width, int height, float current_alt) {
    //PIMAGE img = newimage(getwidth(), getheight());
    //settarget(img);  // 所有绘图操作将指向这个图层
    // 清除图层背景为透明 (RGBA)
    //setbkcolor(EGERGBA(0, 0, 0, 0));
    //cleardevice();
    
    //参数矫正
    //current_alt /= 80;

    int scaleWidth = width;            // 使用参数传入的宽度
    int scaleHeight = height;          // 使用参数传入的高度
    int topY = y;
    int bottomY = y + scaleHeight;  // 高度尺底部Y坐标
    int centerX = x + scaleWidth / 2; // 表盘中心X坐标（相对于左上角）
    ege_enable_aa(true);
    // 背景设置 - 使用灰色背景 (60,60,60)
    setfillcolor(EGERGBA(60, 60, 60, 255));
    bar(x + scaleWidth * 0.12, topY, x + scaleWidth / 1.5, bottomY);

    // 绘制高度尺左右边线 (白色)
    setcolor(WHITE);
    setlinestyle(PS_SOLID, 8);
    setlinewidth(height/150);
    ege_line(x + scaleWidth / 1.5, topY, x + scaleWidth / 1.5, bottomY);
    //上下边线
    ege_line(x + scaleWidth * 0.12, y + scaleHeight * 0.03, x + scaleWidth / 1.2, y + scaleHeight * 0.03);
    ege_line(x + scaleWidth * 0.12, bottomY - scaleHeight * 0.03, x + scaleWidth / 1.2, bottomY - scaleHeight * 0.03);

    // 绘制刻度线和标签 (白色)
    setlinestyle(PS_SOLID, 4);
	setlinewidth(height / 150);
    // ------ 最小修改开始 ------
    const float displayRange = 5800.0f; // 固定显示范围（英尺）
    float pixelsPerFoot = static_cast<float>(scaleHeight) / (displayRange * 2.0f);
    
    // 计算最小和最大显示高度
    float minHeight = current_alt - displayRange / 100.0f;
    float maxHeight = current_alt + displayRange / 100.0f;
    // ------ 最小修改结束 ------

    // 每100英尺高度对应的像素数 (保持原样，实际未使用)
    float pixelsPer100Feet = (float)scaleHeight / (maxHeight - minHeight) * 100.0f;

    // 计算主要刻度起点(最低的100英尺刻度)
    int startAlt = static_cast<int>(minHeight) - (static_cast<int>(minHeight) % 100);
    if (minHeight < 0) startAlt -= 100;

    // 绘制刻度线 (白色)
    for (int alt = startAlt; alt <= static_cast<int>(maxHeight); alt += 10) {
        if (alt < minHeight) continue;

        // ------ 最小修改：重新计算Y位置 ------
        // 使用当前高度中心点和高度差计算位置
        float yPos = topY + scaleHeight / 2.0f + (current_alt - alt) * pixelsPerFoot * 100.0f;

        // 决定刻度线类型 (保持原样)
        // 绘制刻度线 (白色) (保持原样)
        setcolor(WHITE);
        if (alt % 10 == 0)
            ege_line(x + scaleWidth * 0.55, yPos, x + scaleWidth / 1.5, yPos);

        // 每10英尺绘制标签 (白色) (保持原样)
        if (alt % 20 == 0) {
            setcolor(WHITE);
            setfont(width / 4, 0, "Arial");

            char altStr[10];
            sprintf_s(altStr, sizeof(altStr), "%03d", abs(alt));
            ege_drawtext(altStr, x + scaleWidth * 0.15, yPos - height / 40);
        }
    }

    // 绘制当前高度指示器 (保持原样)
    int currentY = topY + scaleHeight / 2;
    setcolor(EGEARGB(255, 255, 255, 0));
    setfillcolor(EGEARGB(255, 255, 255, 0));
    setlinewidth(width / 50);
    ege_line(x + scaleWidth * 0.52, y + scaleHeight / 2, x + scaleWidth / 1.5, y + scaleHeight / 2);
    ege_point points[4] = {
        {x + scaleWidth / 1.5, y + scaleHeight * 0.5},
        {x + scaleWidth / 1.3, y + scaleHeight * 0.49},
        {x + scaleWidth / 1.3, y + scaleHeight * 0.51},
        {x + scaleWidth / 1.5, y + scaleHeight * 0.5},
    };
    setlinewidth(width / 50);
    ege_drawpoly(4, points);
    ege_fillpoly(4, points);
    
    //绘制上下遮挡层 (保持原样)
    setfillcolor(BLACK);
    ege_fillrect(x, y - scaleHeight * 0.03, scaleWidth / 1.2 - scaleWidth * 0.12, scaleHeight * 0.055);
    ege_fillrect(x, y + scaleHeight * 0.975, scaleWidth / 1.2 - scaleWidth * 0.12, scaleHeight * 0.055);

    //settarget(NULL);
    //putimage_withalpha(NULL, img, x, y, 0, 0, getwidth(), getheight());
    //putimage_withalpha(NULL, mask_layer, 0, 0, 0, 0, getwidth(), getheight());
    // 清理资源
    //delimage(img);
}//空速

 //（实际上是高度）
void drawSpeed(int x, int y, int width, int height, float current_speed) {
	x += width * 4.5;
	int scaleWidth = width;
	int scaleHeight = height;
	int topY = y;
	int bottomY = y + scaleHeight;
	int centerX = x + scaleWidth / 2;
	ege_enable_aa(true);

	// 背景设置
	setfillcolor(EGERGBA(60, 60, 60, 255));
	bar(x + scaleWidth * 0.12, topY, x + scaleWidth / 1.5, bottomY);

	// 绘制边框
	setcolor(WHITE);
	setlinestyle(PS_SOLID, 8);
	setlinewidth(height / 150);
	ege_line(x + scaleWidth / 1.5, topY, x + scaleWidth / 1.5, bottomY);
	ege_line(x + scaleWidth * 0.12, y + scaleHeight * 0.03, x + scaleWidth / 1.2, y + scaleHeight * 0.03);
	ege_line(x + scaleWidth * 0.12, bottomY - scaleHeight * 0.03, x + scaleWidth / 1.2, bottomY - scaleHeight * 0.03);

	// ------ 关键修改：添加固定显示范围 ------
	const float displayRange = 600.0f; // 添加固定显示范围（50节）
	float pixelsPerKnot = static_cast<float>(scaleHeight) / (displayRange * 2.0f);

	// 修改minHeight和maxHeight的计算
	float minHeight = current_speed - displayRange;
	float maxHeight = current_speed + displayRange;
	// ------ 修改结束 ------

	// 每1节高度对应的像素数（未使用）
	float pixelsPer100Feet = (float)scaleHeight / (maxHeight - minHeight) * 100.0f;

	// 计算主要刻度起点
	int startAlt = static_cast<int>(minHeight) - (static_cast<int>(minHeight) % 100);
	if (minHeight < 0) startAlt -= 100;

	// 绘制刻度线
	for (int alt = startAlt; alt <= static_cast<int>(maxHeight); alt += 100) {
		if (alt < minHeight) continue;

		// 计算Y位置（修改为基于固定范围的计算）
		// float ratio = (float)(maxHeight - alt) / altRange;
		// int yPos = topY + static_cast<int>(ratio * scaleHeight);
		float yPos = topY + scaleHeight / 2.0f + (current_speed - alt) * pixelsPerKnot;

		// 绘制刻度线 (白色)
		setcolor(WHITE);
		ege_line(x + scaleWidth * 0.58, yPos, x + scaleWidth / 1.5, yPos);

		// 标签显示
		if (alt % 500 == 0) {
			setcolor(WHITE);
			setfont(width / 3.6, 0, "Arial");

			char altStr[10];
			sprintf_s(altStr, sizeof(altStr), "%03d", abs(alt/100));
			ege_drawtext(altStr, x + scaleWidth * 0.15, yPos - height / 40);
		}
	}
	// 中侧遮挡
	setfillcolor(BLACK);
	setlinewidth(width / 30);
	ege_fillrect(x + scaleWidth * 0.11, topY + scaleHeight * 0.42, scaleWidth * 0.54, scaleHeight * 0.1);
	setcolor(EGEARGB(255, 255, 255, 0));
	ege_line(x + scaleWidth * 0.11, topY + scaleHeight * 0.42, scaleWidth * 0.56 + x + scaleWidth * 0.1, topY + scaleHeight * 0.42);
	ege_line(x + scaleWidth * 0.11, topY + scaleHeight * 0.52, scaleWidth * 0.56 + x + scaleWidth * 0.1, topY + scaleHeight * 0.52);
	ege_line(x + scaleWidth / 1.5, topY + scaleHeight * 0.4, scaleWidth * 0.2 + x + scaleWidth * 0.7, topY + scaleHeight * 0.4);
	ege_line(x + scaleWidth / 1.5, topY + scaleHeight * 0.54, scaleWidth * 0.2 + x + scaleWidth * 0.7, topY + scaleHeight * 0.54);
	ege_line(scaleWidth * 0.2 + x + scaleWidth * 0.7, topY + scaleHeight * 0.4, scaleWidth * 0.2 + x + scaleWidth * 0.7, topY + scaleHeight * 0.54);

	// 在黄色框中显示实时速度值
	setcolor(EGEARGB(255,0,255,0));
	setfont(height / 12, 0, "黑体");
	char curr_str[20];
	sprintf(curr_str, "%.0f", current_speed/100);
	int text_width = textwidth(curr_str);
	outtextxy(x + scaleWidth * 0.11, topY + scaleHeight * 0.43, curr_str);

	// 绘制右侧小框内的循环小数字
	const int tens_values[] = { 0, 10, 20, 30, 40, 50, 60, 70, 80, 90 };
	const float y_offsets[] = { 0.405f, 0.449f, 0.495f };
	const int num_displays = 3;
	int tens_index = (int)(current_speed / 10) % 10;
	setfont(height / 18, 0, "Courier New");
	//setcolor(WHITE);
	for (int i = 0; i < num_displays; i++) {
		int display_index = (tens_index + i) % 10;
		int tens_value = tens_values[display_index];
		char tens_str[3];
		sprintf(tens_str, "%02d", tens_value);
		int text_width = textwidth(tens_str);
		int text_x = x + scaleWidth * 0.88 - text_width;
		int text_y = topY + (int)(scaleHeight * y_offsets[i]);
		outtextxy(text_x, text_y, tens_str);
	}

	// 绘制当前高度指示器
	int currentY = topY + scaleHeight / 2;
	setcolor(WHITE);
	const int pointerWidth = 15;
	setlinestyle(PS_SOLID, 2);

	// 绘制上下遮挡层
	setfillcolor(BLACK);
	ege_fillrect(x, y - scaleHeight * 0.03, scaleWidth / 1.2 - scaleWidth * 0.12, scaleHeight * 0.055);
	ege_fillrect(x, y + scaleHeight * 0.975, scaleWidth / 1.2 - scaleWidth * 0.12, scaleHeight * 0.055);
}
//姿态
void drawAttitudeIndicator(int x0, int y0, int width, int height, float radius, float pitch, float roll) {
	//PIMAGE main_layer = newimage(width, height);
	
	//pitch *= getwidth() / width;
	//数据矫正 pitch
	//上
	if (pitch <= 10&&pitch>=0)
		pitch /= 4.8;
	else if (pitch > 10)
		pitch /= 4.2;
	else if(pitch>20)
		pitch /= 2;
	//下
	if (pitch < 0)
		pitch /= 5.3;
	else if (pitch < -10)
		pitch /= 25;
	else if (pitch < -20)
		pitch /= 4;
	//数据矫正 roll
	//roll *= 0.7;
	// 参数校验
	if (radius <= 0) return;

	// 计算缩放因子
	float scale = radius / 300.0f;
	float bg_radius = radius * 0.85f;
	
	// 计算俯仰偏移（带限幅）
	float pitch_offset = 100.0f;
	float bg_height_scale = 3.0f;

	// 定义不同的上下限幅阈值
	float pitch_limit_up = 8.0f;    // 上限幅较大
	float pitch_limit_down = 5.0f; // 下限幅较小

	// 计算俯仰偏移（上下不对称限幅）
	if (pitch <= pitch_limit_up && pitch >= -pitch_limit_down) {
		if (pitch >= 0) {
			// 上半部分使用较大限幅阈值
			pitch_offset = (pitch / pitch_limit_up) * 400.0f * scale;
		}
		else {
			// 下半部分使用较小限幅阈值
			pitch_offset = (pitch / pitch_limit_down) * 250.0f * scale;
		}
	}
	else if (pitch > pitch_limit_up) {
		pitch_offset = 450.0f * scale;
	}
	else {
		pitch_offset = -300.0f * scale;
	}

	// 创建图层（扩大到旋转后可能需要的尺寸）
	float expansion = 1.5f; // 扩大比例
	int layer_width = (int)(4 * radius * expansion);
	int layer_height = (int)(4 * radius * expansion);
	PIMAGE layer = newimage(layer_width, layer_height);

	// 设置图层为目标，开始绘制
	settarget(layer);
	// 清空图层（透明背景）
	cleardevice();
	ege_enable_aa(true);

	// 在图层坐标系中计算中心点（相对于图层的位置）
	float layer_center_x = (float)layer_width / 2.0f;
	float layer_center_y = (float)layer_height / 2.0f;

	// 绘制天空和地面背景
	setfillcolor(EGEARGB(255, 0, 110, 226)); // 天空蓝色
	ege_fillrect(layer_center_x - 3 * bg_radius / 2,
		layer_center_y - 4.7 * bg_radius / 2 + pitch_offset,
		3 * bg_radius,
		bg_radius * 4.7 / 2);

	setfillcolor(EGEARGB(255, 123, 42, 38)); // 地面棕色
	ege_fillrect(layer_center_x - 3 * bg_radius / 2,
		layer_center_y + pitch_offset,
		3 * bg_radius,
		bg_radius * 2.5);

	// 绘制地平线（白色）
	setlinecolor(WHITE);
	setlinewidth(radius / 70);
	ege_line(layer_center_x - bg_radius, layer_center_y + pitch_offset,
		layer_center_x + bg_radius, layer_center_y + pitch_offset);

	// 绘制俯仰刻度
	float pitch_increment = 30.0f * scale;
	float length = 2 * radius; // 用于字体缩放
	setcolor(EGERGB(255, 255, 255));
	setbkmode(TRANSPARENT);
	for (int i = -16; i <= 12; i++) {
		if (i == 0 || (i > 6 && i % 4 != 0) || i < -12 && i != -16) continue; // 跳过线
		float line_offset = layer_center_y + pitch_offset + i * pitch_increment;
		float line_length = (i % 2 == 0) ? bg_radius * 0.1f : bg_radius * 0.06f;
		if (i % 4 == 0 || i > 3) {
			line_length = bg_radius * 0.2f;
			//setcolor(EGERGB(255, 255, 255));
		}
		ege_line(layer_center_x - line_length, line_offset,
			layer_center_x + line_length, line_offset);
	}
	float line_offset = layer_center_y + pitch_offset + pitch_increment;
	float line_length = (1 % 2 == 0) ? bg_radius * 0.1f : bg_radius * 0.06f;
	setfont(length * 0.0544, 0, "Arial");
	setcolor(WHITE);
	ege_drawtext("10", layer_center_x - line_length - bg_radius / 3.1, line_offset - bg_radius / 1.6);
	ege_drawtext("10", layer_center_x - line_length + bg_radius / 3, line_offset - bg_radius / 1.6);
	ege_drawtext("20", layer_center_x - line_length - bg_radius / 3.1, line_offset - bg_radius * 1.1);
	ege_drawtext("20", layer_center_x - line_length + bg_radius / 3, line_offset - bg_radius * 1.1);
	ege_drawtext("30", layer_center_x - line_length - bg_radius / 3.1, line_offset - bg_radius * 1.57);
	ege_drawtext("30", layer_center_x - line_length + bg_radius / 3, line_offset - bg_radius * 1.57);
	ege_drawtext("50", layer_center_x - line_length - bg_radius / 3.1, line_offset - bg_radius * 2.07);
	ege_drawtext("50", layer_center_x - line_length + bg_radius / 3, line_offset - bg_radius * 2.07);

	ege_drawtext("10", layer_center_x - line_length - bg_radius / 3.1, line_offset + bg_radius * 0.3);
	ege_drawtext("10", layer_center_x - line_length + bg_radius / 3, line_offset + bg_radius * 0.3);
	ege_drawtext("20", layer_center_x - line_length - bg_radius / 3.1, line_offset + bg_radius * 0.55);
	ege_drawtext("20", layer_center_x - line_length + bg_radius / 3, line_offset + bg_radius * 0.55);
	ege_drawtext("30", layer_center_x - line_length - bg_radius / 3.1, line_offset + bg_radius * 0.8);
	ege_drawtext("30", layer_center_x - line_length + bg_radius / 3, line_offset + bg_radius * 0.8);
	//绘制上部特殊符号
	setcolor(EGEARGB(255, 255, 0, 0));
	ege_point red[7] = {
		{layer_center_x - line_length + bg_radius * 0.12, line_offset - bg_radius * 1.9},
		{layer_center_x - line_length + bg_radius * 0.2, line_offset - bg_radius * 1.9},
		{layer_center_x , line_offset - bg_radius * 1.65},
		{layer_center_x + line_length - bg_radius * 0.2, line_offset - bg_radius * 1.9},
		{layer_center_x + line_length - bg_radius * 0.12, line_offset - bg_radius * 1.9},
		{layer_center_x , line_offset - bg_radius * 1.78},
		{layer_center_x - line_length + bg_radius * 0.12, line_offset - bg_radius * 1.9}
	};
	ege_drawpoly(7, red);
	ege_point red2[7] = {
		{layer_center_x - line_length + bg_radius * 0.12, line_offset + bg_radius * 1.2},
		{layer_center_x - line_length + bg_radius * 0.2, line_offset + bg_radius * 1.2},
		{layer_center_x , line_offset + bg_radius * 0.95},
		{layer_center_x + line_length - bg_radius * 0.2, line_offset + bg_radius * 1.2},
		{layer_center_x + line_length - bg_radius * 0.12, line_offset + bg_radius * 1.2},
		{layer_center_x , line_offset + bg_radius * 1.08},
		{layer_center_x - line_length + bg_radius * 0.12, line_offset + bg_radius * 1.2}
	};
	ege_drawpoly(7, red2);
	//绘制上下的小遮挡
	setcolor(WHITE);
	setfillcolor(EGEARGB(255, 0, 110, 226));
	line_offset = bg_radius * 3.65; 
	ege_fillrect(layer_center_x - bg_radius / 4 - 1.5 * radius, line_offset - bg_radius * 2.35, 4.5 * bg_radius, 3 * bg_radius / 2);
	ege_rectangle(layer_center_x - bg_radius / 4 - 1.5 * radius, line_offset - bg_radius * 2.35, 4.5 * bg_radius, 3 * bg_radius / 2);
	setfillcolor(EGEARGB(255, 123, 42, 38));
	ege_fillrect(layer_center_x - bg_radius / 4 - 1.5 * radius, line_offset + bg_radius * 0.68, 4.5 * bg_radius, 3 * bg_radius / 2);
	ege_rectangle(layer_center_x - bg_radius / 4 - 1.5 * radius, line_offset + bg_radius * 0.68, 4.5 * bg_radius, 3 * bg_radius / 2);

	ege_point points[4] = {
	   {layer_center_x * 1, line_offset - bg_radius * 1.06},             // 顶点
	   {layer_center_x - bg_radius * 0.05,line_offset - bg_radius * 0.98}, // 左下点
	   {layer_center_x + bg_radius * 0.05,line_offset - bg_radius * 0.98},  // 右下点
	   {layer_center_x * 1,line_offset - bg_radius * 1.06 }             // 闭合点
	};
	ege_point points1[5] = {
		{layer_center_x - bg_radius * 0.07,line_offset - bg_radius * 0.95},
		{ layer_center_x + bg_radius * 0.07,line_offset - bg_radius * 0.95 },
		{ layer_center_x + bg_radius * 0.09,line_offset - bg_radius * 0.91 },
		{ layer_center_x - bg_radius * 0.09,line_offset - bg_radius * 0.91 },
		{layer_center_x - bg_radius * 0.07,line_offset - bg_radius * 0.95},
	};
	setcolor(EGEARGB(255, 255, 255, 0));
	setlinewidth(bg_radius * 0.015); // 设置线宽
	// 绘制三角形
	ege_drawpoly(4, points);
	ege_drawpoly(5, points1);

	// 创建遮挡图层 
	PIMAGE mask_layer = newimage(GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN));
	settarget(mask_layer);
	cleardevice();
	// 设置透明背景
	setbkcolor(EGEARGB(0, 0, 0, 0), mask_layer);
	// 绘制黑色遮挡元素（使用您提供的参数）
	setfillcolor(BLACK);
	// 左侧矩形
	ege_fillrect(x0 - radius * 1.75, y0 - radius,
		radius * 1, 3 * radius);
	// 右侧矩形
	ege_fillrect(x0 + radius * 3 / 4, y0 - 6 * radius / 3,
		radius * 1.4, 3 * radius);
	//上侧矩形
	ege_fillrect(x0 - 1.75 * radius, y0 - 6 * radius / 3, 3.75 * radius, radius);
	//下侧矩形
	ege_fillrect(x0 - 1.75 * radius, y0 + radius, 4 * radius, radius * 2);
	ege_enable_aa(true);
	//绘制圆弧（粗线形成实心效果）
	setcolor(BLACK);
	//增加线宽形成实心圆弧（使用更粗的线宽）
	setlinewidth(radius / 1.4);
	ege_arc(
		x0 - radius * 1.2, y0 - radius * 1.2,
		2.4 * radius, 2.4 * radius,
		25, 130);
	ege_arc(
		x0 - radius * 1.2, y0 - radius * 1.2,
		2.4 * radius, 2.4 * radius,
		205, 130);
	// 恢复默认绘图目标
	settarget(NULL);
	// 保存当前变换状态
	ege_transform_matrix old_transform;
	ege_get_transform(&old_transform);
	// 应用旋转变换
	ege_transform_matrix new_transform;
	ege_transform_translate(x0, y0);
	ege_transform_rotate(-roll);
	ege_transform_translate(-x0, -y0);

	// 计算图层在屏幕上的位置（居中对齐）
	int draw_x = (int)(x0 - layer_width / 2.0f);
	int draw_y = (int)(y0  - layer_height / 2.0f);

	// 计算源图像的裁剪区域和中心点
	int srcX = (int)(layer_width / 4);
	int srcY = (int)(layer_height / 3.5);
	int srcWidth = width;
	int srcHeight = height;
	float xCenterSrc = layer_center_x;  // 源图像旋转中心x
	float yCenterSrc = layer_center_y;  // 源图像旋转中心y
	float xCenterDest = draw_x + srcX + width / 2;  // 目标旋转中心x
	float yCenterDest = draw_y + srcY + height / 2; // 目标旋转中心y

	setbkcolor(EGEARGB(0, 0, 0, 0), layer);
	ege_drawimage(layer,draw_x,draw_y);
	//putimage(draw_x,draw_y,layer);
	//putimage(draw_x+ layer_width / 4, draw_y+ layer_height / 3.5, width, height, layer, layer_width / 4,layer_height/3.5);
	//settarget(main_layer);
	//roll = 50;
	//int a = putimage_rotatezoom(mask_layer,layer,draw_x + width ,draw_y + height ,0.8,0.8,-roll,1.0f,true,-1,true);
	//if (a == 0)
	//	ege_outtextxy(100, 100, "YES", NULL);
	//settarget(NULL);
	// 恢复原有变换状态
	ege_set_transform(&old_transform);
	//遮挡层
	//setbkcolor(GREEN, mask_layer);

	//setbkcolor(RED, mask_layer);
	putimage_withalpha(NULL, mask_layer, 0, 0 ,0 ,0 , GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN));

	//绘制信息
	setcolor(BLACK);
	setfillcolor(BLACK);
	setcolor(EGEARGB(255, 255, 255, 0));
	setlinewidth(radius / 70);
	float symbolX = x0;
	float symbolY = y0;
	ege_point points2[7] = {
		{symbolX - radius * 0.65f, symbolY - radius * 0.00f},
		{symbolX - radius * 0.35f, symbolY - radius * 0.00f},
		{symbolX - radius * 0.35f, symbolY + radius * 0.12f},
		{symbolX - radius * 0.4f, symbolY + radius * 0.12f},
		{symbolX - radius * 0.4f, symbolY + radius * 0.05f},
		{symbolX - radius * 0.65f, symbolY + radius * 0.05f},
		{symbolX - radius * 0.65f, symbolY - radius * 0.0f}
	};

	// 右侧多边形（基于屏幕中心）
	ege_point points3[7] = {
		{symbolX + radius * 0.65f, symbolY - radius * 0.00f},
		{symbolX + radius * 0.35f, symbolY - radius * 0.00f},
		{symbolX + radius * 0.35f, symbolY + radius * 0.12f},
		{symbolX + radius * 0.4f, symbolY + radius * 0.12f},
		{symbolX + radius * 0.4f, symbolY + radius * 0.05f},
		{symbolX + radius * 0.65f, symbolY + radius * 0.05f},
		{symbolX + radius * 0.65f, symbolY - radius * 0.0f}
	};

	ege_fillpoly(7, points2);
	ege_drawpoly(7, points2);
	ege_fillpoly(7, points3);
	ege_drawpoly(7, points3);
	ege_fillrect(x0 - radius * 0.024, y0, radius * 0.045, radius * 0.045);
	ege_rectangle(x0 - radius * 0.024, y0, radius * 0.045, radius * 0.045);
	//四个箭头
	setcolor(WHITE);
	ege_point points4[3] = {
		{x0 + bg_radius * 0.63, y0 - bg_radius * 0.47},
		{x0 + bg_radius * 0.73,y0 - bg_radius * 0.47},
		{x0 + bg_radius * 0.73,y0 - bg_radius * 0.39},
	};
	ege_point points5[3] = {
		{x0 - bg_radius * 0.63, y0 - bg_radius * 0.47},
		{x0 - bg_radius * 0.73, y0 - bg_radius * 0.47},
		{x0 - bg_radius * 0.73, y0 - bg_radius * 0.39},
	};
	ege_point points6[3] = {
		{x0 - bg_radius * 0.63,y0 + bg_radius * 0.55},
		{x0 - bg_radius * 0.73, y0 + bg_radius * 0.55},
		{x0 - bg_radius * 0.73, y0 + bg_radius * 0.46},
	};
	ege_point points7[3] = {
		{x0 + bg_radius * 0.63, y0 + bg_radius * 0.55},
		{x0 + bg_radius * 0.73, y0 + bg_radius * 0.55},
		{x0 + bg_radius * 0.73, y0 + bg_radius * 0.46},
	};
	ege_drawpoly(3, points4);
	ege_drawpoly(3, points5);
	ege_drawpoly(3, points6);
	ege_drawpoly(3, points7);

	// 删除图层
	delimage(layer);
	delimage(mask_layer);
}
void drawBackGround(int x, int y, int length, int wideth, double size) {
	//基本背景
	setcolor(EGERGB(int(175), int(175), int(175)));
	setlinewidth(2 * size);
	for (int i = 1; i <= 4; i++) {
		ege_line(x + (length / 5) * i, y, x + (length / 5) * i, y + (length / 6.2));
	}
	ege_line(x, y + wideth * 0.75, x + length, y + wideth * 0.75);
	ege_line(x + 2 * (length / 5), y + wideth * 0.75, x + 2 * (length / 5), y + wideth);
	//左下角
	setlinewidth(2 * size);
	ege_point polypoints1[4] = { {x + (length / 5) * 0.5,y + wideth * 0.90},{x + (length / 5) * 0.4,y + wideth * 0.905},{x + (length / 5) * 0.4,y + wideth * 0.91},{x + (length / 5) * 0.5,y + wideth * 0.915} };
	ege_bezier(4, polypoints1);
	ege_point polypoints2[4] = { {x + (length / 5) * 0.5,y + wideth * 0.90},{x + (length / 5) * 0.7,y + wideth * 0.895},{x + (length / 5) * 0.9,y + wideth * 0.895},{x + (length / 5) * 1.1,y + wideth * 0.90} };
	ege_bezier(4, polypoints2);
	ege_line(x + (length / 5) * 0.5, y + wideth * 0.90, x + (length / 5) * 0.5, y + wideth * 0.915);
	ege_line(x + (length / 5) * 0.5, y + wideth * 0.915, x + (length / 5) * 1.25, y + wideth * 0.915);
	ege_line(x + (length / 5) * 1.1, y + wideth * 0.90, x + (length / 5) * 1.1, y + wideth * 0.915);
	ege_line(x + (length / 5) * 1.1, y + wideth * 0.90, x + (length / 5) * 1.25, y + wideth * 0.915);
}
void drawFD(int x, int y, int length, int wideth, double size) {
	setcolor(EGERGB(int(175), int(175), int(175)));
	setlinewidth(2 * size);
	setfont(length * 0.0444, 0, "黑体");
	setbkmode(TRANSPARENT);
	setfont(length * 0.0511, 0, "黑体");
	outtextxy(x + length * 0.835, y + wideth / 11, "A/THR");
	setcolor(EGERGB(int(175), int(1715), int(175)));
}
//垂直速度表
void drawVerticalSpeed(int x, int y, int length, int wideth, double speed, double size) {
	//数据矫正
	speed /= 100;
	speed = (int)speed;
	setfillcolor(EGERGB(int(90), int(90), int(90)));
	ege_point vertical[7] = { {x + length * 0.91, y + wideth * 0.2},{x + length * 0.94, y + wideth * 0.2},{x + length * 0.97, y + wideth * 0.3},{x + length * 0.97, y + wideth * 0.55},{x + length * 0.94, y + wideth * 0.65},{x + length * 0.91, y + wideth * 0.65},{x + length * 0.91, y + wideth * 0.2} };
	ege_fillpoly(7, vertical);
	//中间黄线
	setlinewidth(4 * size);
	setcolor(EGERGB(246, 246, 4));
	ege_line(x + length * 0.91, y + wideth * 0.425, x + length * 0.94, y + wideth * 0.425);
	//白色刻度
	setcolor(EGERGB(int(175), int(175), int(175)));
	setlinewidth(5 * size);//大刻度
	setfont(length * 0.0422, 0, "Tahoma");
	ege_line(x + length * 0.93, y + wideth * 0.22, x + length * 0.94, y + wideth * 0.22);
	outtextxy(x + length * 0.91, y + wideth * 0.2, "6");
	ege_line(x + length * 0.93, y + wideth * 0.27, x + length * 0.94, y + wideth * 0.27);
	outtextxy(x + length * 0.91, y + wideth * 0.25, "2");
	ege_line(x + length * 0.93, y + wideth * 0.32, x + length * 0.94, y + wideth * 0.32);
	outtextxy(x + length * 0.91, y + wideth * 0.3, "1");
	ege_line(x + length * 0.93, y + wideth * 0.53, x + length * 0.94, y + wideth * 0.53);
	outtextxy(x + length * 0.91, y + wideth * 0.51, "1");
	ege_line(x + length * 0.93, y + wideth * 0.58, x + length * 0.94, y + wideth * 0.58);
	outtextxy(x + length * 0.91, y + wideth * 0.56, "2");
	ege_line(x + length * 0.93, y + wideth * 0.63, x + length * 0.94, y + wideth * 0.63);
	outtextxy(x + length * 0.91, y + wideth * 0.61, "6");
	setlinewidth(2 * size);//小刻度
	ege_line(x + length * 0.93, y + wideth * 0.245, x + length * 0.945, y + wideth * 0.245);
	ege_line(x + length * 0.93, y + wideth * 0.295, x + length * 0.945, y + wideth * 0.295);
	ege_line(x + length * 0.93, y + wideth * 0.3725, x + length * 0.945, y + wideth * 0.3725);
	ege_line(x + length * 0.93, y + wideth * 0.4775, x + length * 0.945, y + wideth * 0.4775);
	ege_line(x + length * 0.93, y + wideth * 0.555, x + length * 0.94, y + wideth * 0.555);
	ege_line(x + length * 0.93, y + wideth * 0.605, x + length * 0.94, y + wideth * 0.605);
	//绿线
	setlinewidth(2 * size);
	setcolor(EGERGB(int(0), int(175), int(0)));
	if (fabs(speed) > 60)
		setcolor(EGERGB(157, 97, 60));
	char s[5];
	sprintf_s(s, "%.0f", fabs(speed));
	if (speed < 10 && speed > 0) {
		ege_line(x + length * 0.931, y + wideth * 0.425 - ((y + wideth * 0.425 + -y - wideth * 0.32) / 10) * speed, x + length * 0.98, y + wideth * 0.425);
		outtextxy(x + length * 0.931, y + wideth * 0.395 - ((y + wideth * 0.425 + -y - wideth * 0.32) / 10) * speed, s);
	}
	if (speed > 10 && speed <= 20) {
		ege_line(x + length * 0.931, y + wideth * 0.32 - ((y + wideth * 0.32 + -y - wideth * 0.27) / 10) * (speed - 10), x + length * 0.98, y + wideth * 0.425);
		outtextxy(x + length * 0.931, y + wideth * 0.29 - ((y + wideth * 0.32 + -y - wideth * 0.27) / 10) * (speed - 10), s);
	}
	if (speed > 20 && speed <= 60) {
		ege_line(x + length * 0.931, y + wideth * 0.27 - ((y + wideth * 0.27 + -y - wideth * 0.22) / 40) * (speed - 20), x + length * 0.98, y + wideth * 0.425);
		outtextxy(x + length * 0.931, y + wideth * 0.24 - ((y + wideth * 0.27 + -y - wideth * 0.22) / 40) * (speed - 20), s);
	}
	if (speed > 60) {
		ege_line(x + length * 0.931, y + wideth * 0.22, x + length * 0.98, y + wideth * 0.425);
		outtextxy(x + length * 0.931, y + wideth * 0.19, s);
	}
	//speed为负数
	if (speed < 0 && speed >= -10) {
		ege_line(x + length * 0.931, y + wideth * 0.425 - ((y + wideth * 0.425 + -y - wideth * 0.32) / 10) * speed, x + length * 0.98, y + wideth * 0.425);
		outtextxy(x + length * 0.931, y + wideth * 0.435 - ((y + wideth * 0.425 + -y - wideth * 0.32) / 10) * speed, s);
	}
	if (speed > -20 && speed < -10) {
		ege_line(x + length * 0.931, y + wideth * 0.425 - ((y + wideth * 0.32 + -y - wideth * 0.27) / 10) * (speed - 10), x + length * 0.98, y + wideth * 0.425);
		outtextxy(x + length * 0.931, y + wideth * 0.435 - ((y + wideth * 0.32 + -y - wideth * 0.27) / 10) * (speed - 10), s);
	}
	if (speed > -60 && speed <= -20) {
		ege_line(x + length * 0.931, y + wideth * 0.53 - ((y + wideth * 0.27 + -y - wideth * 0.22) / 40) * (speed - 20), x + length * 0.98, y + wideth * 0.425);
		outtextxy(x + length * 0.931, y + wideth * 0.54 - ((y + wideth * 0.27 + -y - wideth * 0.22) / 40) * (speed - 20), s);
	}
	if (speed < -60) {
		ege_line(x + length * 0.931, y + wideth * 0.63, x + length * 0.98, y + wideth * 0.425);
		outtextxy(x + length * 0.931, y + wideth * 0.64, s);
	}
	if (speed == 0) {
		ege_line(x + length * 0.91, y + wideth * 0.425, x + length * 0.98, y + wideth * 0.425);
	}
}
//航向仪
void draw_heading(int x, int y, int width, int height, float current_heading) {
	int scaleWidth = width;
	int scaleHeight = height;
	int topY = y;
	int bottomY = y + scaleHeight;
	int centerY = y + scaleHeight / 2;

	ege_enable_aa(true);

	// 背景设置
	setfillcolor(EGERGBA(60, 60, 60, 255));
	bar(x, topY + scaleHeight * 0.12, x + scaleWidth, topY + scaleHeight * 1);

	// 绘制边框
	setcolor(WHITE);
	setlinewidth(height / 25);
	ege_line(x, topY + scaleHeight * 0.12, x + scaleWidth, topY + scaleHeight * 0.12);
	ege_line(x + scaleWidth * 0.035, topY + scaleHeight * 0.12, x + scaleWidth * 0.035, topY + scaleHeight * 1);
	ege_line(x + scaleWidth - scaleWidth * 0.035, topY + scaleHeight * 0.12, x + scaleWidth - scaleWidth * 0.035, topY + scaleHeight * 1);

	// 固定显示范围（度）
	const float displayRange = 50.0f;
	float pixelsPerDegree = (float)scaleWidth / displayRange;

	// 计算当前显示的最小和最大航向
	float minHeading = current_heading - displayRange / 2;
	float maxHeading = current_heading + displayRange / 2;

	// 计算第一个可见刻度线的位置（调整为5的倍数）
	float firstTick = ceilf(minHeading / 5.0f) * 5.0f;

	// 绘制刻度线 (白色)
	for (float alt = firstTick; alt <= maxHeading; alt += 5) {
		// 计算实际显示的航向（处理循环）
		int displayAlt = static_cast<int>(alt) % 360;
		if (displayAlt < 0) displayAlt += 360;

		// 计算X位置
		float ratio = (alt - minHeading) / displayRange;
		int xPos = x + static_cast<int>(ratio * scaleWidth);

		// 确保刻度线在可见区域内
		if (xPos >= x && xPos <= x + scaleWidth) {
			// 绘制刻度线
			setcolor(WHITE);
			if (displayAlt % 5 == 0)
				ege_line(xPos, topY + scaleHeight * 0.12, xPos, topY + scaleHeight * 0.3);
			if (displayAlt % 10 == 0)
				ege_line(xPos, topY + scaleHeight * 0.12, xPos, topY + scaleHeight * 0.45);

			// 每10度绘制标签 
			if (displayAlt % 10 == 0) {
				setcolor(WHITE);
				setfont(height / 2, 0, "Arial");

				char altStr[10];
				if (displayAlt == 0) {
					sprintf_s(altStr, sizeof(altStr), "36");
				}
				else {
					sprintf_s(altStr, sizeof(altStr), "%d", displayAlt / 10);
				}
				int textW = textwidth(altStr);
				ege_drawtext(altStr, xPos - textW / 2, topY + scaleHeight * 0.5);
			}
		}
	}

	// 绘制当前航向指示器
	int currentX = x + scaleWidth / 2;
	setcolor(EGEARGB(255, 255, 255, 0));
	setfillcolor(EGEARGB(255, 255, 255, 0));
	setlinewidth(height / 12);
	ege_line(currentX, topY - scaleHeight * 0.35, currentX, topY + scaleHeight * 0.22);

	// 绘制遮挡层
	setfillcolor(BLACK);
	ege_fillrect(x - scaleWidth * 0.33, topY, scaleWidth * 0.36, scaleHeight);
	ege_fillrect(x + scaleWidth - scaleWidth * 0.03, topY, scaleWidth * 0.6, scaleHeight);

	// 绘制绿色指示器
	setcolor(EGEARGB(255, 0, 255, 0));
	setlinewidth(height / 18);
	ege_point GreenPoint[5] = {
		{x + scaleWidth / 2,topY + scaleHeight * 0.17},
		{x + scaleWidth / 2 + scaleWidth * 0.015,topY + scaleHeight * 0.22},
		{x + scaleWidth / 2,topY + scaleHeight * 0.35},
		{x + scaleWidth / 2 - scaleWidth * 0.015,topY + scaleHeight * 0.22},
		{x + scaleWidth / 2,topY + scaleHeight * 0.17}
	};
	ege_drawpoly(5, GreenPoint);
}
//上方ALT
void drawAlt2(int x, int y, int length, int wideth, double size) {
	setcolor(EGERGB(int(175), int(175), int(175)));
	setlinewidth(2 * size);
	setfont(length * 0.0444, 0, "黑体");
	setbkmode(TRANSPARENT);
	outtextxy(x + length * 0.835, y + wideth / 19, "1 FD 2");
	setcolor(EGERGB(int(0), int(175), int(175)));
	setlinewidth(1 * size);
	setfont(length * 0.0489, 0, "Tahoma");
	setbkmode(TRANSPARENT);
	setcolor(EGERGB(int(0), int(175), int(175)));
	outtextxy(x + length * 0.21, y + wideth / 19, "ALT");
}
//背景
void drawbk(int bk_x, int bk_y, int bk_length, int bk_wideth, double Chuispeed, double size, int VS, double height) {
	drawBackGround(bk_x, bk_y, bk_length, bk_wideth, size);
	drawFD(bk_x, bk_y, bk_length, bk_wideth, size);
	drawVerticalSpeed(bk_x, bk_y, bk_length, bk_wideth, Chuispeed, size);
	drawAlt2(bk_x, bk_y, bk_length, bk_wideth, size);
}
//总背景
void drawPFD(int x1, int y1, int l, int w, double verticalSpeed, double size, int choice, double airSpeed, double height, double airspeedYellow, double translateX, double translateY, int VS, double THR, int choice41, int flap, int SPD, double landing) {
	double x = x1 * size;
	double y = y1 * size;
	double length = l * size;
	double wideth = w * size;
	//sky(x * 0.01 + translateX, -y * 0.548 + translateY * 0.8, 1.86 * size);
	drawbk(x, y, length, wideth, verticalSpeed, size, VS, height);
	//左下角襟翼
	drawLanding(x, y, length, wideth, landing, size);
	//空速和高度
	//drawSpeedAndAlimter(wideth / 12, x + 0.03 * length, y + 0.208 * wideth, x + length * 0.733, airSpeed, height, airspeedYellow, flap, SPD);
	//THR相关
	//if (THR >= 84 && THR < 86) {
	//	drawSpeedMin(x, y, length, wideth, size);
	//}
	//if (THR >= 86 && THR < 100) {
	//	drawSpeedMidum(x, y, length, wideth, size);
	//}
	//if (THR >= 100) {
	//	drawSpeedMax(x, y, length, wideth, size);
	//}
	//襟翼相关
	/*switch (choice) {
	case 1:
		drawwings1(x, y, length, wideth, size, brightness);
		break;
	case 2:
		drawwings2(x, y, length, wideth, size, brightness);
		break;
	case 3:
		drawwings3(x, y, length, wideth, size, brightness);
		break;
	case 4:
		drawwings4(x, y, length, wideth, size, brightness);
		break;
	case 0:
		break;
	}*/
	//FD相关
	if (choice41 == 1) {
		drawAlt2(x, y, length, wideth, size);
	}
}
//总函数
void draw_PFD(int x0, int y0, double height,double pitch,double roll,double Height,double speed,double heading,double Chuispeed,double landing) {
	double width = height * 872 / 1123;
	int center_x = x0 + width / 2.3;
	int center_y = y0 + height / 2.5;
	float radius = height * 0.21;
	// 1. 模拟数据变化
	//static float t = 0.0f;
	//data.pitch = sin(t / 3) * 20 * 0;
	//data.roll = cos(t / 4) * 50 * 0;
	//data.height = t * 20;
	//data.speed = t * 2;
	//data.heading = t * 1;
	//setviewport(x0, y0, x0 + width, y0 + height);

	// 2. 绘制姿态仪
	drawAttitudeIndicator(center_x, center_y, width, height, radius, pitch, roll);

	// 3. 绘制主PFD
	drawPFD(
		x0, y0, width, height,
		Chuispeed, 1, 1, 250, 3000, 320, 0, 0, 1, 85, 1, 1, 1, landing
	);

	// 4. 绘制高度尺
	drawAirbusAltitudeScale(
		x0 + width * 0.01,
		y0 + height * 0.187,
		width * 0.158,
		height * 0.418,
		Height
	);

	// 5. 绘制速度尺
	drawSpeed(
		x0 + width * 0.01,
		y0 + height * 0.187,
		width * 0.158,
		height * 0.418,
		speed 
	);

	// 6. 绘制航向
	draw_heading(
		x0 + width * 0.2,
		y0 + height * 0.67,
		height * 0.4,
		width * 0.1,
		heading
	);
	//视口裁剪
	//setviewport(x0,y0,x0+width,y0+height);

}
//是否警报
bool is_ring(double Chuispeed) {
	if (fabs(Chuispeed>6000)) {
		return true;//表示会报警
	}
	else
		return false;
}